/* JTableDemo.java 
* Created on Dec 2, 2012 
*@Author: Mr.Viet 
*@Phone: 01683430426 
*@Email: phamvanvietcdhd@gmail.com
*/ 
package com.session5; 

import java.util.Vector;

import javax.swing.JScrollPane;
import javax.swing.JTable;

import net.miginfocom.swing.MigLayout;

public class JTableDemo extends MyFrame {
	private JTable tblStudent;
	private Vector<Vector<String>> vtrData;
	private Vector <String> columns;
	public JTableDemo() {
		this.columns = new Vector<String>();
		this.columns.add("Name");
		this.columns.add("Address");
		this.columns.add("Age");
//		Tao Ra Cac Dong 
		this.vtrData = new Vector<Vector<String>>();
		
//		Khoi Tao Du Lieu Tung Dong Trong Bang
		Vector<String> item1= new Vector<String>();
		item1.addElement("Pham Van Viet");
		item1.addElement("Thanh Ha");
		item1.addElement("21");
		
		Vector<String> item2 =new Vector<String>();
		item2.addElement("Pham Thi Thu");
		item2.addElement("Ha Giang");
		item2.addElement("24");
//		Them Du Lieu Vao Dong
		this.vtrData.addElement(item1);
		this.vtrData.addElement(item2);
	}

	public static void main(String[] args) {
		JTableDemo d = new JTableDemo();
		d.createForm();
		d.showForm();
	}

	@Override
	public void createForm() {
		this.tblStudent = new JTable(this.vtrData,this.columns);
		this.setLayout(new MigLayout());
		this.getContentPane().add(new JScrollPane(this.tblStudent));
	}

}
